
using Progress.Lang.*.



class OpenEdge.WebSpeed.AgentSettings: 

    define temp-table ttAgentSetting
        field cKey  as character
        field cSub  as character
        field cName as character 
        field cVal  as character
        index SettingIdx is primary cKey  cSub
        index NameIdx               cName.


    method public void InitAgentSettings():
        
        
    end.

    /**
     Purpose:  Used to set the value of a Name/Value key to the user-specified 
                    agent setting temp-table.
           Inputs:  cInKey: key name that the name/value is specified under
                    cInSub: sub-key, provides for sub-type orginization. Not required
                    cInName: name of 'variable' that is being requested
                    cInVal: value that the 'variable' is to be set to
          Returns:  Logical ERROR-STATUS:ERROR
            Notes:  
    
    */
    method public logical SetAgentSetting 
        (cInKey  as character,
        cInSub  as character,
        cInName as character,
        cInVal  as character):
        define variable retVal as logical no-undo.

        SettingBLOCK:
        do on error undo SettingBlock, leave SettingBlock:
            find ttAgentSetting where
                ttAgentSetting.cKey  eq cInKey  and
                ttAgentSetting.cSub  eq cInSub  and
                ttAgentSetting.cName eq cInName no-error.
            if not available ttAgentSetting then 
            do:
                create ttAgentSetting.
                assign 
                    ttAgentSetting.cKey  = cInKey
                    ttAgentSetting.cSub  = cInSub
                    ttAgentSetting.cName = cInName NO-ERROR.
            end. /* name/value not available */
   
            ttAgentSetting.cVal = cInVal.
            release ttAgentSetting.
            retVal = error-status:error. 
        end. /* SettingBlock */

        return retVal.

    end .
    
    
    /**
     Purpose:  Used to get the value of a Name/Value key out of the user-specified 
                    agent setting temp-table.
           Inputs:  cInKey: key name that the name/value is specified under
                    cInSub: sub-key, provides for sub-type orginization. Not required
                    cInName: name of 'variable' that is being requested
          Returns:  Value or "" if not available
            Notes:  
    
    */
    method public character GetAgentSetting 
        (cInKey  as character,
        cInSub  as character,
        cInName as character):
        define variable cRetVal as character no-undo.
   
        find ttAgentSetting where
            ttAgentSetting.cKey  eq cInKey and
            ttAgentSetting.cSub  eq cInSub and
            ttAgentSetting.cName begins cInName no-error.

        cRetVal = (if available ttAgentSetting then ttAgentSetting.cVal else "").

        return cRetVal.

    end .    
    
end class.